package org.bozo.im.common.utils;

import org.bozo.im.common.types.Protocol;

import android.provider.ContactsContract.CommonDataKinds.Im;

public class ProtocolUtils {

	public static Protocol fromSystemProtocol(int pProtocol) {

		Protocol lRes;

		switch (pProtocol) {
		case Im.PROTOCOL_GOOGLE_TALK:
			lRes = Protocol.GTALK;
			break;
		case Im.PROTOCOL_JABBER:
			lRes = Protocol.XMPP;
			break;
		case Im.PROTOCOL_CUSTOM:
			lRes = Protocol.FAKE;
			break;
		default:
			lRes = Protocol.FAKE;
		}
		
		return lRes;
	}

	public static int toSystemProtocol(Protocol pProtocol) {

		int lRes;

		switch (pProtocol) {
		case GTALK:
			lRes = Im.PROTOCOL_GOOGLE_TALK;
			break;
		case XMPP:
			lRes = Im.PROTOCOL_JABBER;
			break;
		case FAKE:
			lRes = Im.PROTOCOL_CUSTOM;
			break;

		default:
			lRes = Im.PROTOCOL_CUSTOM;
		}

		return lRes;
	}

}
